package com.ocom.payconfig.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ocom.common.entity.card.EntityPointConfig;
import com.ocom.common.entity.card.EntityXfPointInfo;
import com.ocom.common.entity.human.EntityPersonnelInfo;
import com.ocom.common.request.payconfig.AddSubsidyDataResquest;
import com.ocom.common.vo.payconfig.kitchenprinter.PointConfigOnPointInfoDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoPointConfig extends BaseMapper<EntityPointConfig> {

    @Select({"<script>",
            "select  a.*, b.point_name,\n" +
                    " c.receipt_name, \n" +
                    " b.merch_id \n" +
                    " FROM\n" +
                    " point_config a\n" +
                    " LEFT JOIN xf_point_info b ON a.point_id = b.point_id\n" +
                    " LEFT JOIN receipt_address c ON a.receipt_id = c.receipt_id" +
                    " where " +
                    " a.com_id = #{comId}" +
                    " <when test=\" strPoints !=null and strPoints.size()>0 \" > " +
                    " AND  a.point_id in " +
                    " <foreach collection='strPoints' item='id' open='(' separator=',' close=')'>" +
                    " #{id}" +
                    " </foreach>" +
                    " </when> " +
                    " <when test=\"pointName != null and pointName != '' \"> " +
                    " AND point_name like CONCAT('%', #{pointName}, '%') " +
                    " </when> " +
                    "</script>"})
    List<EntityPointConfig> restaurantList(@Param("comId") Long comId, @Param("strPoints") List<String> strPoints, @Param("pointName") String pointName);

    @Select({"<script>",
            "SELECT\n" +
                    "\tR.rest_id,\n" +
                    "\tR.point_id,\n" +
                    "\tP.point_name\n" +
                    "FROM\n" +
                    "\tpoint_config R\n" +
                    "LEFT JOIN xf_point_info P ON P.point_id = R.point_id\n" +
                    "WHERE\n" +
                    "\tR.com_id = #{comId}\n" +
                    "AND R.point_id = #{pointId}" +
                    "</script>"})
    List<PointConfigOnPointInfoDto> findPointConfigOnPointInfoByPointId(@Param("comId") Long comId, @Param("pointId") Long pointId);
}
